const path = require("path")
const fs = require("fs-extra")

 async function generateTemp(name){
    const workPath = path.resolve(name)
    const templatePath = path.resolve(__dirname,'../templact_vue2')
    await fs.copy(templatePath,workPath)
    const targetTemp = fs.readFileSync(path.resolve(`${name}/package.json`))
    let json = JSON.parse(targetTemp)
    json.name = name
    fs.writeFileSync(path.resolve(`${name}/package.json`),JSON.stringify(json, null, '\t'), 'utf-8')
}

module.exports = generateTemp